package com.damuzee.core.web;

import javax.servlet.http.HttpServletRequest;

import com.damuzee.common.web.spring.MessageResolver;
import com.damuzee.core.util.StringUtil;

public class WebContext {

	// 获取项目部署名称
	private static final String SYSTEM_DESPLOY_NAME = "system.deploy.path";
	// 项目部署的绝对路径
	private static final String SYSEM_CONTEXT_NAME = "sysem.context.name";

	public static String getContextPath(HttpServletRequest request) {
		String contextPath = MessageResolver.getMessage(request,
				SYSTEM_DESPLOY_NAME);
		if (!StringUtil.isBlank(contextPath)) {
			contextPath = request.getContextPath();
		}
		if (contextPath.equals("/")) {
			contextPath = "";
		}
		return contextPath;
	}

	public static String getRealPath(HttpServletRequest request) {

		String deployPath = MessageResolver.getMessage(request,
				SYSTEM_DESPLOY_NAME);
		if (!StringUtil.isBlank(deployPath)) {
			deployPath = request.getRealPath("/");
		}
		return deployPath;

	}
}
